﻿using BusinessBingo.Data.Interfaces;
using BusinessBingo.Model.Interfaces;

namespace BusinessBingo.CommandHandlers.Base
{
    public abstract class BaseCommandHandler
    {
        protected IValidationState _validationState;
        protected IUnitOfWork _unitOfWork;

        protected BaseCommandHandler(IValidationState validationState, IUnitOfWork unitOfWork)
        {
            this._validationState = validationState;
            this._unitOfWork = unitOfWork;
        }

        protected void Complete()
        {
            if(this._validationState.IsValid == true && this.IsMaster == true)
                this._unitOfWork.Commit();
        }

        public bool IsMaster { get; set; }
    }
}